﻿using FieldTools.Client.Business.IBusiness;
using FieldTools.Client.WebApi.Controllers;
using FieldTools.Util;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Microsoft.VisualBasic.ApplicationServices;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FieldTools.Client.Controller
{
    public class HomeController : BaseApiController
    {
        private readonly ILogger<HomeController> _logger;
        private readonly ICustomApiBus _customApiBus;
        public HomeController(ILogger<HomeController> logger, ICustomApiBus customApiBus)
        {
            _logger = logger;
            _customApiBus = customApiBus;
        }
        /// <summary>
        /// get
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        [Route("api/custom/{path}")]
        [HttpGet]
        public string? Get(string path) 
        {
            return _customApiBus.Get(path);
            //return $"自定义get调用成功，路由参数为：{path}";
        }
        /// <summary>
        /// post
        /// </summary>
        /// <param name="path"></param>
        /// <param name="obj"></param>
        /// <returns></returns>
        [Route("api/custom/{path}")]
        [HttpPost]
        public string? Post(string path, object obj) 
        { 
            return _customApiBus.Post(path, obj);
            //return $"自定义post调用成功，路由参数为：{path}，传递参数为：{obj.ToJson()}";
        }
    }
}
